package com.ceshiren.test.houduankaifa.util;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {


    private static final long serialVersionUID = 1L;


    private Integer code;
    private String msg;
    private T data;





    public static <T> Result<T> success() {
        Result<T> result = new Result<T>();
        result.setCode(ResultCode.SUCCESS);
        result.setMsg("成功");
        return result;
    }


    public static <T> Result<T> error() {
        Result<T> result = new Result<T>();
        result.setCode(ResultCode.ERROR);
        result.setMsg("失败");
        return result;
    }


    public Result<T> code(int code) {
        this.setCode(code);
        return this;
    }
    public Result<T> msg(String msg) {
        this.setMsg(msg);
        return this;
    }


    public Result<T> data(T data) {
        this.setData(data);
        return this;
    }

}
